<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .demo::selection{
      background-color: #222;
      color: red
    }
  </style>
</head>
<body>
</body>
<!-- [css] 怎么改变选中文本的文字颜色和背景色？ -->
<!-- ::selection {
  background-color: #222;
  color: white;
  } -->
  <div class="demo">测试文字</div>
</html>